package com.example.light.system.controller;

import com.example.light.system.common.Result;
import com.example.light.system.dto.allUserList;
import com.example.light.system.service.impl.IUserService;
import com.example.light.system.vo.insertUser;
import com.example.light.system.vo.searchUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

@Api(description = "用户管理接口")
@RestController
@RequestMapping("/UserController")
public class UserController {
    @Resource
    IUserService iUserService;

    @ApiOperation("查询所有用户")
    @PostMapping("/searchAllUser")
    public Result<ArrayList<allUserList>> searchAllUser(){
        return iUserService.searchAllUser();
    }

    @ApiOperation("新增用户")
    @PostMapping("/insertUser")
    public Result<String> insertUser(@RequestBody insertUser insertUser){
        return iUserService.insertUser(insertUser);
    }

    @ApiOperation("编辑用户")
    @PostMapping("/editUser")
    Result<String> editUser(@RequestBody insertUser insertUser){
        return iUserService.editUser(insertUser);
    }

    @ApiOperation("删除用户")
    @PostMapping("/deleteUser")
    public Result<String> deleteUser(String userAccount){
        return iUserService.deleteUser(userAccount);
    }

    @ApiOperation("查询用户")
    @PostMapping("/searchUser")
    public Result<ArrayList<allUserList>> searchUser(@RequestBody searchUser searchUser){
        return iUserService.searchUser(searchUser);
    }
}
